home *** CD-ROM | disk | FTP | other *** search
/ MacTech 1 to 12 / MacTech-vol-1-12.toast / Source / MacTech® Magazine / Volume 10 - 1994 / 10.11 Nov 94 / Programmers' Challenge / Factor64.h < prev    next >
Encoding:
C/C++ Source or Header  |  1994-06-12  |  3.9 KB  |  108 lines  |  [TEXT/KAHL]

  1. /*------------------------------------------------------*/
  2. /*   Header file for 64 bit factorization program.        */
  3. /*------------------------------------------------------*/
  4.  
  5. #include <stdio.h>
  6. #include <stdlib.h>
  7. #include <math.h>
  8.  
  9. #define  ulong      unsigned long
  10. #define  ushort  unsigned short
  11.  
  12. typedef  ushort *  Int;
  13.  
  14. ulong    inv(ulong,ushort);
  15. short    qrs(ushort,ushort);
  16. ushort   mrt(ushort,ushort);
  17. ulong    hrt(ulong,ushort);
  18. ushort     npr(ushort);
  19.  
  20. void     Add(Int,Int,Int);
  21. void     Dif(Int,Int,Int);
  22. void     Mul(Int,Int,Int);
  23. void     Mulq(Int,ushort);
  24. void     Mod(Int);
  25. ushort   Modq(Int,ushort);
  26. void     Divq(Int,ushort);
  27. void     Shiftr(Int);
  28. short    Comp(Int,Int);
  29. void     Set(Int,ulong);
  30. ulong    Unset(Int);
  31. ulong     Bitsize(Int);
  32. ulong    Gcd(Int);
  33.  
  34. ushort   buf[20], N[5];
  35. ulong    bufm[20];
  36. double   g;
  37.  
  38. /*------------------------------------------------------*/
  39. /*    Odd primes below 0x800 (and their 10*logs)            */
  40. /*------------------------------------------------------*/
  41.  
  42. ushort Prm[] = {
  43.    3, 11,   5, 17,   7, 20,  11, 24,  13, 26,
  44.   17, 29,  19, 30,  23, 32,  29, 34,  31, 35,
  45.   37, 37,  41, 38,  43, 38,  47, 39,  53, 40,
  46.   59, 41,  61, 42,  67, 43,  71, 43,  73, 43,
  47.   79, 44,  83, 45,  89, 45,  97, 46, 101, 46,
  48.  103, 46, 107, 46, 109, 46, 113, 47, 127, 48,
  49.  131, 48, 137, 49, 139, 49, 149, 50, 151, 50,
  50.  157, 50, 163, 50, 167, 51, 173, 51, 179, 51,
  51.  181, 51, 191, 52, 193, 52, 197, 52, 199, 52,
  52.  211, 53, 223, 54, 227, 54, 229, 54, 233, 54,
  53.  239, 54, 241, 54, 251, 55, 257, 55, 263, 55,
  54.  269, 55, 271, 56, 277, 56, 281, 56, 283, 56,
  55.  293, 56, 307, 57, 311, 57, 313, 57, 317, 57,
  56.  331, 58, 337, 58, 347, 58, 349, 58, 353, 58,
  57.  359, 58, 367, 59, 373, 59, 379, 59, 383, 59,
  58.  389, 59, 397, 59, 401, 59, 409, 60, 419, 60,
  59.  421, 60, 431, 60, 433, 60, 439, 60, 443, 60,
  60.  449, 61, 457, 61, 461, 61, 463, 61, 467, 61,
  61.  479, 61, 487, 61, 491, 61, 499, 62, 503, 62,
  62.  509, 62, 521, 62, 523, 62, 541, 62, 547, 63,
  63.  557, 63, 563, 63, 569, 63, 571, 63, 577, 63,
  64.  587, 63, 593, 63, 599, 63, 601, 63, 607, 64,
  65.  613, 64, 617, 64, 619, 64, 631, 64, 641, 64,
  66.  643, 64, 647, 64, 653, 64, 659, 64, 661, 64,
  67.  673, 65, 677, 65, 683, 65, 691, 65, 701, 65,
  68.  709, 65, 719, 65, 727, 65, 733, 65, 739, 66,
  69.  743, 66, 751, 66, 757, 66, 761, 66, 769, 66,
  70.  773, 66, 787, 66, 797, 66, 809, 66, 811, 66,
  71.  821, 67, 823, 67, 827, 67, 829, 67, 839, 67,
  72.  853, 67, 857, 67, 859, 67, 863, 67, 877, 67,
  73.  881, 67, 883, 67, 887, 67, 907, 68, 911, 68,
  74.  919, 68, 929, 68, 937, 68, 941, 68, 947, 68,
  75.  953, 68, 967, 68, 971, 68, 977, 68, 983, 68,
  76.  991, 68, 997, 69,1009, 69,1013, 69,1019, 69,
  77. 1021, 69,1031, 69,1033, 69,1039, 69,1049, 69,
  78. 1051, 69,1061, 69,1063, 69,1069, 69,1087, 69,
  79. 1091, 69,1093, 69,1097, 70,1103, 70,1109, 70,
  80. 1117, 70,1123, 70,1129, 70,1151, 70,1153, 70,
  81. 1163, 70,1171, 70,1181, 70,1187, 70,1193, 70,
  82. 1201, 70,1213, 71,1217, 71,1223, 71,1229, 71,
  83. 1231, 71,1237, 71,1249, 71,1259, 71,1277, 71,
  84. 1279, 71,1283, 71,1289, 71,1291, 71,1297, 71,
  85. 1301, 71,1303, 71,1307, 71,1319, 71,1321, 71,
  86. 1327, 71,1361, 72,1367, 72,1373, 72,1381, 72,
  87. 1399, 72,1409, 72,1423, 72,1427, 72,1429, 72,
  88. 1433, 72,1439, 72,1447, 72,1451, 72,1453, 72,
  89. 1459, 72,1471, 72,1481, 73,1483, 73,1487, 73,
  90. 1489, 73,1493, 73,1499, 73,1511, 73,1523, 73,
  91. 1531, 73,1543, 73,1549, 73,1553, 73,1559, 73,
  92. 1567, 73,1571, 73,1579, 73,1583, 73,1597, 73,
  93. 1601, 73,1607, 73,1609, 73,1613, 73,1619, 73,
  94. 1621, 73,1627, 73,1637, 74,1657, 74,1663, 74,
  95. 1667, 74,1669, 74,1693, 74,1697, 74,1699, 74,
  96. 1709, 74,1721, 74,1723, 74,1733, 74,1741, 74,
  97. 1747, 74,1753, 74,1759, 74,1777, 74,1783, 74,
  98. 1787, 74,1789, 74,1801, 74,1811, 75,1823, 75,
  99. 1831, 75,1847, 75,1861, 75,1867, 75,1871, 75,
  100. 1873, 75,1877, 75,1879, 75,1889, 75,1901, 75,
  101. 1907, 75,1913, 75,1931, 75,1933, 75,1949, 75,
  102. 1951, 75,1973, 75,1979, 75,1987, 75,1993, 75,
  103. 1997, 75,1999, 76,2003, 76,2011, 76,2017, 76,
  104. 2027, 76,2029, 76,2039, 76,   0,  0 };
  105.  
  106. /*------------------------------------------------------*/
  107. /*   End of file Factor64.h                                */
  108. /*------------------------------------------------------*/